<extend name="common:base" />
<block name="content">
    <div id="header">
        <div class="header">
            <h1 class="tit">{$site_title}</h1>
            <!--<p class="goback">-->
                <!--<a class="return" href="{:U('Setting/index')}">返回</a>-->
            <!--</p>-->
            <!--<p class="more"><a class="share" href=""></a></p>-->
        </div>
    </div>
    <div class="banx-a">
        <div class="zm" id="dataList">
            <foreach name="invitations" item="inv">
                <a href="{:U('Setting/agent_view', array('id' =>$inv['beadd_agent']))}">
                    <div class="a">
                        <if condition="$inv['avatar'] neq ''">
                            <img src="{$inv['avatar']}"/>
                            <else/><img src="__PUBLIC__/images/default.png"/>
                        </if>
                        <div class="zl">
                            <p class="zlp">{$inv['agent_name']}&nbsp;&nbsp;{$inv['rank_name']}</p>
                            <p class="zlp2">手机：{$inv['mobile']}</p>
                        </div>
                    </div>
                </a>
            </foreach>
        </div>
    </div>
    <div class="dropload-load" id="loading" style="display: none;"><span class="loading"></span>加载中...</div>
</block>
<block name="CSS">
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/groom_users.css" />
</block>
<block name="JS">
    <script type="text/javascript">
        $(function() {
            /*设置列表数据*/
            function setListData(data){
                var listDom = document.getElementById("dataList");
                for (var i = 0; i < data.length; i++) {
                    var pd = data[i];
                    var str = '<a href="{:U('Setting/agent_view')}&id='+ pd.beadd_agent+ '">';
                    str += "<div class='a'>";
                    if(pd.avatar){
                        str += "<img src='" + pd.avatar +"'>";
                    }else{
                        str += "<img src='__PUBLIC__/images/default.png'>";
                    }
                    str += '<div class="zl">';
                    str += '<p class="zlp">' + pd.agent_name + '&nbsp;&nbsp;' + pd.rank_name + '</p>';
                    str += '<p class="zlp2">手机：' + pd.mobile + '</p>';
                    str += '</div>';
                    str += '</div>';
                    str += '</a>';

                    var liDom = document.createElement("div");
                    liDom.innerHTML = str;
                    listDom.appendChild(liDom);//加在列表的后面,上拉加载
                }
            }

            var pagenum = 1;
            $(window).scroll(function(){

                var scrollTop = $(this).scrollTop();
                var scrollHeight = $(document).height();
                var windowHeight = $(this).height();

                if(scrollTop + windowHeight == scrollHeight){
                    pagenum += 1;
                    $.ajax({
                        url:"{:U('Setting/get_more')}",
                        type: "post",
                        data: {
                            params: "{$params}",
                            page:pagenum
                        },
                        success: function(data) {
                            $('#loading').show();
                            setTimeout(function(){
                                if(data){
                                    setListData(data)
                                }else{
                                    $("#loading").text("亲没有更多的数据了！");
                                    $("#loading").show();
                                }
                            }, 700);
                        }
                    });
                }
            });

        });
    </script>
</block>